package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProAdjust;
import com.ruoyi.system.service.IProAdjustService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 计划调整记录Controller
 * 
 * @author ruoyi
 * @date 2024-10-08
 */
@RestController
@RequestMapping("/system/adjust")
public class ProAdjustController extends BaseController
{
    @Autowired
    private IProAdjustService proAdjustService;

    /**
     * 查询计划调整记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:adjust:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProAdjust proAdjust)
    {
        startPage();
        List<ProAdjust> list = proAdjustService.selectProAdjustList(proAdjust);
        return getDataTable(list);
    }

    /**
     * 导出计划调整记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:adjust:export')")
    @Log(title = "计划调整记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProAdjust proAdjust)
    {
        List<ProAdjust> list = proAdjustService.selectProAdjustList(proAdjust);
        ExcelUtil<ProAdjust> util = new ExcelUtil<ProAdjust>(ProAdjust.class);
        util.exportExcel(response, list, "计划调整记录数据");
    }

    /**
     * 获取计划调整记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:adjust:query')")
    @GetMapping(value = "/{adjustId}")
    public AjaxResult getInfo(@PathVariable("adjustId") Long adjustId)
    {
        return success(proAdjustService.selectProAdjustByAdjustId(adjustId));
    }

    /**
     * 新增计划调整记录
     */
    @PreAuthorize("@ss.hasPermi('system:adjust:add')")
    @Log(title = "计划调整记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProAdjust proAdjust)
    {
        return toAjax(proAdjustService.insertProAdjust(proAdjust));
    }

    /**
     * 修改计划调整记录
     */
    @PreAuthorize("@ss.hasPermi('system:adjust:edit')")
    @Log(title = "计划调整记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProAdjust proAdjust)
    {
        return toAjax(proAdjustService.updateProAdjust(proAdjust));
    }

    /**
     * 删除计划调整记录
     */
    @PreAuthorize("@ss.hasPermi('system:adjust:remove')")
    @Log(title = "计划调整记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{adjustIds}")
    public AjaxResult remove(@PathVariable Long[] adjustIds)
    {
        return toAjax(proAdjustService.deleteProAdjustByAdjustIds(adjustIds));
    }
}
